package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单商品关联的报价商品（物料）
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-22
 */
@Entity
@Table(schema = "public", name = "ord_material", indexes = {@Index(name = "ord_material_product_id_idx", columnList = "order_product_id")})
public class OrderMaterialDO implements Serializable {
    private static final long serialVersionUID = -5566927923925974697L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_material_seq")
    @SequenceGenerator(sequenceName = "ord_material_seq", name = "ord_material_seq", allocationSize = 1)
    private Long id;

    /**
     * 一对一双向关联订单商品
     */
    @JsonBackReference
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="order_product_id",referencedColumnName="id")
    private OrderProductDO orderProduct;

    /**
     * 报价单Id
     */
    @Column
    private Long quotedId;

    /**
     * 关联的商品Id
     */
    @Column
    private Long productId;

    /**
     * 关联的商品skuId
     */
    @Column
    private Long skuId;

    /**
     * 关联商品的编号
     */
    @Column(columnDefinition = "varchar(30)")
    private String productNo;

    /**
     * 报价商品名称
     */
    @Column(columnDefinition = "varchar(100)")
    private String name;

    /**
     * 报价商品规格
     */
    @Column(columnDefinition = "varchar(255)")
    private String spec;

    /**
     * 报价商品品类
     */
    @Column(columnDefinition = "varchar(50)")
    private String category;

    /**
     * 报价商品品牌
     */
    @Column(columnDefinition = "varchar(50)")
    private String brand;

    /**
     * 供应商库存
     */
    @Column(columnDefinition = "numeric(15,4)")
    private BigDecimal stock;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public OrderProductDO getOrderProduct() {
        return orderProduct;
    }

    public void setOrderProduct(OrderProductDO orderProduct) {
        this.orderProduct = orderProduct;
    }

    public Long getQuotedId() {
        return quotedId;
    }

    public void setQuotedId(Long quotedId) {
        this.quotedId = quotedId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public String getProductNo() {
        return productNo;
    }

    public void setProductNo(String productNo) {
        this.productNo = productNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public BigDecimal getStock() {
        return stock;
    }

    public void setStock(BigDecimal stock) {
        this.stock = stock;
    }
}
